<template>
  <!-- 商品列表 -->
  <ul class="goodslist">
    <li class="goodsitem"
        v-for="(item ,index) in mall_List"
        :key="index">
      <div class="checkbox"
           v-if="isEdit">
        <img v-if="item.isChecked"
             :src="imgOss+'/checked.png'"
             alt
             @click="changeChecked(item)" />
        <img v-if="!item.isChecked"
             :src="imgOss+'/check.png'"
             alt
             @click="changeChecked(item)" />
      </div>
      <div class="main"
           @click="toMalldetail(item)">
        <div class="top">
          <div class="logo">
            <img class="img"
                 v-if="item.thumb_image"
                 :src="imgUrl+item.thumb_image"
                 alt />
            <img class="xiajia"
                 v-if="item.status==1"
                 :src="imgOss+'/xiajia.png'"
                 alt />
            <div class="mallImg_top"
                 v-if="item.tag_name && item.tag_name !== null">{{item.tag_name?item.tag_name:''}}</div>
            <div v-if="item.activity_status == 1"
                 class="shop_type">即将开抢</div>
            <div v-if="item.activity_status == 2"
                 class="shop_type">抢购中</div>
          </div>
          <div class="goodsinfo">
            <div class="title">
              {{item.title}}
            </div>
            <div class="sale">销量 {{item.sales_num}}</div>
            <div class="box">
              <div>
                <span class="yang"
                      v-if="item.price!=0||item.deduction_credit_type==0">¥</span>
                <span class="price"
                      v-if="item.price!=0||item.deduction_credit_type==0">{{item.price}}</span>
                <!-- <span class="addicon" v-if="item.deduction_credit_type!=0&&item.price!=0">+</span> -->
                <img class="addicon"
                     v-if='imgOss&&item.deduction_credit_type!=0&&item.price!=0'
                     :src="imgOss+'/mp_3.1.6/mmk_3.1.6/jyb_add.png'"
                     alt="">
                <span class="addnum"
                      v-if="item.deduction_credit_type==1">{{item.deduction_credit}}</span>
                <img class="icon"
                     v-if="imgOss&&item.deduction_credit_type==1"
                     :src="imgOss+'/mp_3.1.6/goldcoin/gold.png'"
                     alt="">
                <span class="addnum addnum_y"
                      v-if="item.deduction_credit_type==2">{{item.deduction_credit}}</span>
                <img class="icon"
                     v-if="imgOss&&item.deduction_credit_type==2"
                     :src="imgOss+'/mp_3.1.6/goldcoin/silver.png'"
                     alt="">
              </div>
              <div class="tags">
                <span v-if="item.cross_border == 1">跨境</span>
                <span v-if="item.activity_status == 2">秒杀</span>
              </div>
            </div>
          </div>
        </div>
        <div class="bottom">
          <img class="plus"
               v-if="imgOss"
               :src="imgOss+'/collection/plus.png'"
               alt="">
          <p class="plustitle"
             v-if="item.plus_title&&item.plus_title!=''">{{item.plus_title}}</p>
        </div>
      </div>
    </li>
  </ul>
</template>

<script>
import common from "@/assets/js/mmk_common.js";
export default {
  data () {
    return {
      imgUrl: common.image_response,
      imgOss: common.image_resource
    };
  },
  props: {
    isEdit: false,
    mall_List: []
  },
  watch: {
    mall_List (newval, oldval) {
      this.mall_List = newval;
    }
  },
  methods: {
    // 点击选中
    changeChecked (item) {
      item.isChecked = !item.isChecked;
      this.$emit("shopClick", this.mall_List);
    },
    //到商城商品详情
    toMalldetail (params) {
      if (params.status == 1) {
        return;
      }
      wx.navigateTo({
        url: `/pages/package_mall/goods_detail/main?goods_id=${
          params.id
          }&title=${params.title}`
      });
    }
  }
};
</script>

<style scoped lang="less">
/* 商品列表样式 */
.goodslist {
  margin: 10px 10px 0;
  box-sizing: border-box;
  .goodsitem {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    margin-bottom: 10px;
    .checkbox {
      width: 20px;
      height: 20px;
      margin-right: 15px;
      img {
        width: 20px;
        height: 20px;
      }
    }
    .main {
      width: 100%;
      background: rgba(255, 255, 255, 1);
      box-shadow: 0px 2px 6px 0px rgba(240, 240, 240, 1);
      border-radius: 5px;
      padding: 10px 10px 0;
      box-sizing: border-box;
      .top {
        display: flex;
        .logo {
          width: 90px;
          height: 90px;
          border-radius: 6px;
          margin-right: 10px;
          position: relative;
          img {
            width: 100%;
            height: 100%;
            display: block;
            border-radius: 6px;
          }
          .xiajia {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 10;
          }
          .mallImg_top {
            background: url("https://h5.ameimeika.com/mp_images/mp_2.7/icon_intergralmall_list_tag.png")
              no-repeat;
            background-size: 100% 100%;
            line-height: 15px;
            height: 22px;
            text-align: center;
            position: absolute;
            top: -4px;
            left: -4px;
            font-size: 9px;
            font-family: "Medium";
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
            padding: 0 2px;
          }
          .shop_type {
            position: absolute;
            right: 6px;
            bottom: 6px;
            width: 50px;
            text-align: center;
            color: #fff;
            background: linear-gradient(
              213deg,
              rgba(255, 134, 105, 1) 0%,
              rgba(254, 106, 156, 1) 100%
            );
            border-radius: 20px;
            padding: 1px 0;
            font-size: 10px;
          }
        }
        .goodsinfo {
          flex: 7;
          position: relative;
          .title {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(51, 51, 51, 1);
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }
          .sale {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(153, 153, 153, 1);
            line-height: 16px;
          }
          .box {
            width: 100%;
            position: absolute;
            bottom: 0;
            display: flex;
            justify-content: space-between;
            div {
              font-family: PingFangSC-Regular, PingFang SC;
              .yang {
                font-size: 12px;
                font-weight: 400;
                color: #ff383e;
                line-height: 16px;
                margin-right: 1px;
              }
              .price {
                font-size: 16px;
                font-weight: 500;
                color: #ff383e;
                line-height: 20px;
                margin-right: 2px;
              }
              .addicon {
                width: 6px;
                height: 6px;
                // display: inline-block;
                vertical-align: 4px;
                margin: 0 3px 0 1px;
              }
              .addnum {
                font-size: 16px;
                font-weight: 500;
                color: #f5d040;
                line-height: 20px;
                &.addnum_y {
                  color: #beccce;
                }
              }
              .icon {
                width: 15px;
                height: 15px;
                vertical-align: -2px;
              }
            }
            .tags {
              span {
                display: inline-block;
                width: 22px;
                height: 12px;
                line-height: 12px;
                background: #ffeff0;
                border-radius: 2px;
                text-align: center;
                font-size: 9px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #ff383e;
                margin-left: 4px;
              }
            }
          }
        }
      }
      .bottom {
        display: flex;
        align-items: center;
        position: relative;
        padding: 12px 0;
        .plus {
          width: 29px;
          height: 16px;
          margin-right: 4px;
        }
        .plustitle {
          width: 90%;
          font-size: 12px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(102, 102, 102, 1);
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
      }
    }
  }
}
</style>
